import Swiper from 'swiper';
import 'swiper/css/swiper.min.css'
export default {
    data() {
        return {
            // swiperOption:{
            //     loop: true,
			// 	autoplay: {
			// 		delay: 3000,
			// 		stopOnLastSlide: false,
          	// 		disableOnInteraction: false
			// 	},
            //     // 分页
			// 	pagination: {
			// 		el: '.swiper-pagination',
            //         type: 'fraction',
			// 		clickable: true
			// 	}
            // },
            swiper:{},
            //列表
            list:[],
        }
    },
    created() {
        console.log('swiperPublic')
        // this.getList()
    },
    mounted() {
        setTimeout(() => {
            this.mapSwiper()
        }, 1000);
    },
    methods: {
         mapSwiper() {
            if(this.swiperDomData){
                this.swiperDomData.forEach(it=>{
                    console.log(it,9999111111)
                    this.getSwiper(it)
                })
            }
        },
        getSwiper(it) {
            console.log(it,9999222222)
            this['swiper'+it.id] = new Swiper(it.container, {
                loop: it.loop==true?true:false, // 无缝
                // loop: true,
                autoplay:false,
                // autoplay: { //自动开始
                //     delay: 1000, //时间间隔
                //     disableOnInteraction: false, //*手动操作轮播图后不会暂停*
                // },
                paginationClickable: true,
                slidesPerView: it.sideNum, // 一组三个
                spaceBetween: 30, // 间隔
                // loopedSlides: it.loop==true?parseInt(it.sideNum)+2:it.sideNum,
                // 如果需要前进后退按钮
                navigation: {
                    nextEl: it.next,
                    prevEl: it.prev,

                },
                // 窗口变化,重新init,针对F11全屏和放大缩小,必须加
                observer: true,
                observeParents: true,
                // 如果需要分页器
                pagination: {
                    el: it.pagination,
                    clickable: true, // 分页器可以点击
                },
                thumbs:{
                    swiper: this['swiper7']&&it.id==4?this['swiper7']:'',
                },
                on:{
                    slideChange:(e)=>{
                        if(it.id == 4){
                            this.activeTeacherIndex = 'teacherId'+this.homeData.teacher[this.$refs.mysWipper111.swiper.realIndex].teacher_id
                            
                            console.log(this.$refs.mysWipper111.swiper.realIndex,'swiper.activeIndex')

                        }
                    }
                }
            });
            // if(this['swiper4']&&this['swiper8']){
            //     this['swiper4'].controller.control = this['swiper8'];
            //     this['swiper8'].controller.control = this['swiper4'];
            // }// swiper双向控制
            // this['swiper'+it.id].on ('slideChange', (e) => {
            //     console.log(e,this['swiper'+it.id].activeIndex,'askjxbashjjkb')

            //     //this.swiperContainer.activeIndex; 当前切换的组件索引index
            // })
            // if(it.id == 4){
            //     this['swiper'+it.id].on('sideChange',(e)=>{
            //         console.log(e,this['swiper'+it.id].activeIndex,'askjxbashjjkb')
            //     })
            // }
        },
        // nextSlide() {
        //     this.$nextTick(() => { // 等待DOM更新完成后再执行操作
        //       const swiper = this.$refs['my-swiper'].swiper; // 获取Swiper对象
        //       if (swiper) {
        //         swiper.slideNext(); // 切换到下一个Swiper Slide
        //       } else {
        //         console.error('未能获取到Swiper对象');
        //       }
        //     });
        //   },
        
    }
}